/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package data;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Mr. Tam
 */
@Entity
@Table(name = "Complaint")
@NamedQueries({
    @NamedQuery(name = "Complaint.findAll", query = "SELECT c FROM Complaint c"),
    @NamedQuery(name = "Complaint.findByComplaintId", query = "SELECT c FROM Complaint c WHERE c.complaintId = :complaintId"),
    @NamedQuery(name = "Complaint.findByComplaintTitle", query = "SELECT c FROM Complaint c WHERE c.complaintTitle = :complaintTitle"),
    @NamedQuery(name = "Complaint.findByComplaintDescription", query = "SELECT c FROM Complaint c WHERE c.complaintDescription = :complaintDescription"),
    @NamedQuery(name = "Complaint.findByLodgeDate", query = "SELECT c FROM Complaint c WHERE c.lodgeDate = :lodgeDate"),
    @NamedQuery(name = "Complaint.findByFixDate", query = "SELECT c FROM Complaint c WHERE c.fixDate = :fixDate"),
    @NamedQuery(name = "Complaint.findByClosingDate", query = "SELECT c FROM Complaint c WHERE c.closingDate = :closingDate")})
public class Complaint implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "complaint_id")
    private Integer complaintId;
    @Column(name = "complaint_title")
    private String complaintTitle;
    @Column(name = "complaint_description")
    private String complaintDescription;
    @Column(name = "lodge_date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date lodgeDate;
    @Column(name = "fix_date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fixDate;
    @Column(name = "closing_date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date closingDate;
    @JoinColumn(name = "assigned_staff_id", referencedColumnName = "staff_id")
    @ManyToOne
    private Staff staff;
    @JoinColumn(name = "staff_id", referencedColumnName = "staff_id")
    @ManyToOne
    private Staff staff1;
    @JoinColumn(name = "priority_id", referencedColumnName = "priority_id")
    @ManyToOne
    private Priority priority;
    @JoinColumn(name = "complaint_type_id", referencedColumnName = "complaint_type_id")
    @ManyToOne
    private ComplaintType complaintType;
    @JoinColumn(name = "complaint_status_id", referencedColumnName = "complaint_status_id")
    @ManyToOne
    private ComplaintStatus complaintStatus;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "complaint")
    private Solution solution;

    public Complaint() {
    }

    public Complaint(Integer complaintId) {
        this.complaintId = complaintId;
    }

    public Integer getComplaintId() {
        return complaintId;
    }

    public void setComplaintId(Integer complaintId) {
        this.complaintId = complaintId;
    }

    public String getComplaintTitle() {
        return complaintTitle;
    }

    public void setComplaintTitle(String complaintTitle) {
        this.complaintTitle = complaintTitle;
    }

    public String getComplaintDescription() {
        return complaintDescription;
    }

    public void setComplaintDescription(String complaintDescription) {
        this.complaintDescription = complaintDescription;
    }

    public Date getLodgeDate() {
        return lodgeDate;
    }

    public void setLodgeDate(Date lodgeDate) {
        this.lodgeDate = lodgeDate;
    }

    public Date getFixDate() {
        return fixDate;
    }

    public void setFixDate(Date fixDate) {
        this.fixDate = fixDate;
    }

    public Date getClosingDate() {
        return closingDate;
    }

    public void setClosingDate(Date closingDate) {
        this.closingDate = closingDate;
    }

    public Staff getStaff() {
        return staff;
    }

    public void setStaff(Staff staff) {
        this.staff = staff;
    }

    public Staff getStaff1() {
        return staff1;
    }

    public void setStaff1(Staff staff1) {
        this.staff1 = staff1;
    }

    public Priority getPriority() {
        return priority;
    }

    public void setPriority(Priority priority) {
        this.priority = priority;
    }

    public ComplaintType getComplaintType() {
        return complaintType;
    }

    public void setComplaintType(ComplaintType complaintType) {
        this.complaintType = complaintType;
    }

    public ComplaintStatus getComplaintStatus() {
        return complaintStatus;
    }

    public void setComplaintStatus(ComplaintStatus complaintStatus) {
        this.complaintStatus = complaintStatus;
    }

    public Solution getSolution() {
        return solution;
    }

    public void setSolution(Solution solution) {
        this.solution = solution;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (complaintId != null ? complaintId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Complaint)) {
            return false;
        }
        Complaint other = (Complaint) object;
        if ((this.complaintId == null && other.complaintId != null) || (this.complaintId != null && !this.complaintId.equals(other.complaintId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "data.Complaint[complaintId=" + complaintId + "]";
    }

}
